<?php
namespace app\admin\model;

use think\Model;

class User extends Model{

    private $userModel;
    public function __construct(){
        parent::__construct();
        $this -> userModel = db('user');
    }

    /*  添加用户
     *  @param Array [data]
     * **/
    public function addUser( $data = false ){
        $result = $this -> userModel ->  insertGetId($data);
        return $result;
    }

    /*  用户列表
     *  @param Array [where]
     * **/
    public function getUserList( $where = false , $order  = false , $num = 10 , &$page){
        $userData = $this -> userModel -> where($where) -> order($order) -> paginate(10,false,['query'=>request()->param() ]);

        $page = $userData->render();
        $data = iterator_to_array($userData);

        if(empty($data)){   return [];  };
        return $data;
    }

    /*  修改用户
     *  @param Array [where][save]
     * **/
    public function modifyUserData($where, $save){
        $result = $this -> userModel -> where($where) -> update($save);
        return $result;
    }


}